Private Sub cmdOnError_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdOnError.Click

    Dim lngFileSize As Long
    Dim intLoopCtr As Integer
    Dim intBufferCount As Integer
    Dim strInByte As String
    'Set the length of the strInbyte string
    strInByte = Space(256)
    ' If the destination file exists, ask the user if they
    ' want to continue
    If Dir(txtTargetFile.Text) <> "" Then
        If MsgBox(txtTargetFile.Text & vbCrLf & _
            " already exists. Copy over old file?", _
              MsgBoxStyle.OKCancel) = MsgBoxResult.Cancel Then
        End If
    End If

    ' Get the size of the file to copy
    ' and calculate the number of times to loop
    ' the copy routine based on moving 256 bytes at a time
    lngFileSize = FileLen(txtTargetFile.Text)
    intBufferCount = lngFileSize / 256

    ' Open the source and destination files
    FileOpen(1, txtSourceFile.Text, OpenMode.Binary)
    FileOpen(2, txtTargetFile.Text, OpenMode.Binary)

    ' This routine loops until the entire file is copied
    For intLoopCtr = 1 To intBufferCount + 1
        FileGet(1, strInByte)
        FilePut(2, strInByte)
    Next intLoopCtr

    ' After the copy is complete close both files
    FileClose(1)     ' Close file.
    FileClose(2)     ' Close file.
    ' Inform the user that the function is complete
    MsgBox("Copy function complete", MsgBoxStyle.Information)
End Sub
